package com.amon.amonplayer.rxjava.schedulder;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public abstract class Schedulers {
    private static Schedulers IO;

    static {
        IO = new IoSchedulers();
    }

    public static Schedulers io() {
        return IO;
    }

    public abstract void scheduleDirect(Runnable runnable);

    private static class IoSchedulers extends Schedulers {
        ExecutorService service;

        public IoSchedulers() {
            service = Executors.newScheduledThreadPool(1, Thread::new);
        }

        @Override
        public void scheduleDirect(Runnable runnable) {
            service.execute(runnable);
        }
    }
}
